<?php
	namespace app\models\test_study;
	use yii\db\ActiveRecord;
	class table2 extends ActiveRecord{
		public function rules(){
			//更多变量类型查手册的核心验证器
			return [
				['id','integer'],
				['title','string','length'=>[0,8]]
			];
		}
		public function insert(){
			$table2 = new table2;
			$table2->id = '14';
			$table2->title = 't10';
			$table2->validate();//启用验证器，model里面的rules函数
			if($table2->hasErrors())
				echo "data has errors";
			else{
				$table2->save();
				echo "insert data success";
			}
		}
	} 
?>